﻿using System;
using System.Collections.Generic;
using CORE;
using System.Web;
using System.Web.Mvc;

namespace KM.Areas.KM.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /KM/Home/

        public ActionResult Index(string thanhpho)
        {
            //set cookies cho thanh pho
            if (Utils.getIntQuery("LSP") != 0)
            {
                Response.Cookies["thanhpho"].Value = Utils.getIntQuery("LSP").ToString();
                Response.Cookies["thanhpho"].Expires = DateTime.Now.AddDays(1d);
                thanhpho = Utils.GetTenThanhPho(Utils.getIntQuery("LSP"));
                return RedirectToAction("Index","Home", new { thanhpho = thanhpho });
            }
            else
            {
                if (thanhpho == "" || thanhpho == null)
                {
                    thanhpho = Utils.GetTenThanhPho(Utils.getIntCookies("thanhpho"));
                    return RedirectToAction("Index", "Home", new { thanhpho = thanhpho });
                }
            }

            ViewBag.thanhpho = thanhpho;
            ViewBag.Title = Constants.TITLE;
            ViewBag.Description = Constants.DESCRIPTION;
            ViewBag.Keywords = Constants.KEYWORDS;
            return View();
        }

    }
}
